package com.wejoy.video.middle.station.admin.controller.overtime;

import com.wejoy.video.middle.station.admin.controller.BaseController;
import com.wejoy.video.middle.station.admin.util.CurrentUserUtils;
import com.wejoy.video.middle.station.data.domain.overtime.OvertimePoint;
import com.wejoy.video.middle.station.data.domain.system.SysUser;
import com.wejoy.video.middle.station.data.service.overtime.IOvertimePointService;
import com.wejoy.video.middle.station.data.util.WJAssert;
import com.wejoy.video.middle.station.data.vo.RespJSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.ArrayList;

/**
 * 加班点位
 *
 * @author miracle_j
 * @date 2024年04月22日 15:25:48
 */
@RestController
@RequestMapping("/overtime/overtimePoint")
public class OvertimePointController extends BaseController {

    @Autowired
    private IOvertimePointService overtimePointService;

    /**
     * 保存或更新
     *
     * @param overtimePointReq overtimePointReq
     * @return RespJSON
     */
    @PostMapping("/save")
    public RespJSON save(@RequestBody OvertimePoint overtimePointReq, @SessionAttribute(CurrentUserUtils.SYSTEM_USER) SysUser loginSysUser) {
        overtimePointService.save(overtimePointReq, loginSysUser.getName());
        return RespJSON.success();
    }


    /**
     * 主键查询
     *
     * @param id id
     * @return RespJSON
     */
    @RequestMapping("/getOneById")
    public RespJSON getOneById(Long id) {
        return RespJSON.success(overtimePointService.getOneById(id));
    }

    /**
    * 审核
    *
    * @param id id
    * @return RespJSON
    */
    @PostMapping("/audit")
    @ResponseBody
        public RespJSON audit(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER)SysUser loginSysUser) {
        WJAssert.notNull(id, "ID 不合法");
        overtimePointService.audit(id, loginSysUser.getName());
        return RespJSON.success();
    }

    /**
    * 取消审核
    *
    * @param id id
    * @return RespJSON
    */
    @PostMapping("/unaudit")
    @ResponseBody
        public RespJSON unaudit(Long id, @SessionAttribute(CurrentUserUtils.SYSTEM_USER)SysUser loginSysUser) {
        WJAssert.notNull(id, "ID 不合法");
        overtimePointService.unaudit(id, loginSysUser.getName());
        return RespJSON.success();
    }

}
